package com.egao.oa.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.oa.mapper.BugsMapper;
import com.egao.oa.entity.Bugs;
import com.egao.oa.service.BugsService;
import org.springframework.stereotype.Service;
import com.egao.oa.biz.BugsBiz;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 系统测试服务实现类
 * @author : Doman
 * @date : 2020-08-14 16:51:05
 * @version ：1.0
 */
@Service
public class BugsServiceImpl /*extends ServiceImpl<BugsMapper, Bugs> */implements BugsService {

	@Autowired
	private BugsBiz bugsBiz;

    /**
    @Override
    public PageResult<Bugs> listPage(PageParam<Bugs> page) {
        List<Bugs> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Bugs> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Bugs bugs, User loginUser)  throws Exception{
        return bugsBiz.list(page,bugs,loginUser);
    }

    @Override
    public List<Bugs> list(Bugs bugs, User loginUser) {
        return bugsBiz.list(bugs,loginUser);
    }

    @Override
    public JsonResult getById(Bugs bugs) {
        return JsonResult.ok().setData(bugsBiz.getById(bugs));
    }

    @Transactional
    @Override
    public JsonResult save(Bugs bugs, User loginUser) {
        if (bugsBiz.save(bugs, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(Bugs bugs, User loginUser) {
        if (bugsBiz.update(bugs, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(Bugs bugs, User loginUser) {
        if (bugsBiz.remove(bugs, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
